from socket import *
import select

serSocket = socket(AF_INET,SOCK_STREAM)
serAddr = ("",7788)
serSocket.bind(serAddr)
serSocket.setsockopt(SOL_SOCKET,SO_REUSEADDR,1)
serSocket.listen(10)

inputs = [serSocket,]
while True:
    readable,writeable,exceptable = select.select(inputs,[],[])
    for sock in readable:
        if sock == serSocket:
            clientSocket,clientAddr = sock.accept()
            inputs.append(clientSocket)
        else:
            recvData = sock.recv(1024)
            if recvData:
                sock.send(recvData)
                print(recvData)
            else:
                inputs.remove(sock)
                sock.close()
serSocket.close()